package com.example.springapp.service.serviceImpl;

import com.example.springapp.mapper.ManualMapper;
import com.example.springapp.entity.Manual;
import com.example.springapp.service.ManualService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("ManualService")
public class ManualServiceImpl implements ManualService {
    @Resource
    private ManualMapper manualMapper;

    public List<Manual> queryAll() {
        return manualMapper.queryAll();
    }

    public void updateManual(Manual manual) {
        if(manual.getName().equals(""))
            manual.setName(new Date().toString());
        if(manual.getId() > 0)
            manualMapper.updateManual(manual);
        else
            manualMapper.insertManual(manual);
    }
}
